class Person(val name: String) {
    private val id = Person.newPersonID()
    
    def info(): Unit = {
        printf("The id of %s is %d.\n",name,id)
    }
}

object Person {
    private var lastID = 0
        
    def newPersonID() = {
        lastID += 1
        lastID
    }   
    
    def main(args: Array[String]): Unit = {
        val p1 = new Person("Tom")
        val p2 = new Person("Cat")
        
        p1.info()
        p2.info()
    }
}
